<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link href="css/login.css" rel="stylesheet"/>
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="js/login.js"></script>
    <script src="js/jquery.cookie.js"></script>
    <title>登录</title>
</head>
<body>
<div id="login">
    <!--<div id="header">-->
        <!--<img class="back" src="images/back.png" alt="">-->
    <!--</div>-->

    <div id="content">
        <div id="logo">
            <img class="logo" src="images/logo.png"  alt="">
            <h1>欢迎登陆CN</h1>
        </div>
        <form action="" id="form">
            <input type="text" id="tel" placeholder="手机号码">
            <!--<div id="msg"></div>-->
            <input type="password" id="password" placeholder="密码">
            <img src="images/close.png" alt="" id="bt1" class="img1">
            <img src="images/open.png" alt="" id="bt2" class="img1" >
            <div class="meihua">
                <label><input type="checkbox" id="aaa" checked="checked"><span></span></label>
                <p>记住密码</p>
            </div>
            <div id="msg"></div>
        </form>
        <div id="button">
            <button class="login">登录</button>
        </div>
        <div class="forget">
            <a href="login_forgetPassword.html" id="forgetPassword">忘记密码</a>
        </div>
    </div>
    <div id="bottom">
        <strong>还没有云网账号？<a href="register.html" id="zhuce">注册</a></strong>
    </div>
</div>
<script>
    localStorage.clear();
    localStorage.success = 1;
	localStorage.erro = 0;

    $(function(){
        $(document).ready(function() {
            if ($.cookie("rmbUser") == "true") {
                $("#aaa").attr("checked", true);
                $("#tel").val($.cookie("userName"));
                $("#password").val($.cookie("passWord"));
            }
        });
        $(".meihua span").click(function () {
            console.log(($(":checkbox").get(0).checked))
        // function saveUserInfo() {
            if (($(":checkbox").get(0).checked)) {
                var userName = $("#tel").val();
                var passWord = $("#password").val();
                $.cookie("rmbUser", "true", { expires: 7 }); // 存储一个带7天期限的 cookie
                $.cookie("userName", userName, { expires: 7 }); // 存储一个带7天期限的 cookie
                $.cookie("passWord", passWord, { expires: 7 }); // 存储一个带7天期限的 cookie
                console.log(userName)
                console.log(passWord)
            }
            else {
                $.cookie("rmbUser", "false", { expires: -1 });        // 删除 cookie
                $.cookie("userName", '', { expires: -1 });
                $.cookie("passWord", '', { expires: -1 });
            }
        // }
        })
        // $(".meihua span").click(function () {
        //
        //     if($(":checkbox").get(0).checked){
        //         console.log($("#tel").val())
        //         console.log($("#password").val())
        //     }
        // })




        localStorage.top = "http://grandcoinage.co/";

        $(".login").click(function () {
            $.ajax({
                type: 'POST',
                url:`${localStorage.top}api/user/login`,
                data: {
                    account:$("#tel").val(),
                    password:$("#password").val(),
                },

                success:function (data) {
                    console.log(data);
                    if(data.code==0){
                        $("#msg").html(data.msg);
                    }else {
                        $(window).attr('location',"../../yunlianbi/index.html");
                        // console.log(data.data.userinfo.token)
                        localStorage.token=data.data.userinfo.token;
                        localStorage.tan=1;
                    }
                }
            });
        })

        $("#form .img1").click(function(){
            if($("#password").attr("type")=="text"){
                $("#password").attr("type", "password");
                $('#bt1').show();
                $("#bt2").hide();
            }else{
                $("#password").attr("type", "text");
                $('#bt1').hide();
                $("#bt2").show();
            }
        });
    })
</script>


</body>
</html>